package log;

import org.aspectj.lang.ProceedingJoinPoint;

/**
 * @Author: fancyears·milos·malvis
 * @Description:
 * @Date: Created in  2019/4/22 17:23
 * @Modified By:
 */
public class Logger {
    /**
     * This is the method which I would like to execute
     * before a selected method execution.
     */
    public void beforeAdvice(){
        System.out.println("init---------Going to setup object profile.");
    }
    /**
     * This is the method which I would like to execute
     * after a selected method execution.
     */
    public void afterAdvice(){
        System.out.println("setup-----------Object profile has been setup.");
    }
    /**
     * This is the method which I would like to execute
     * when any method returns.
     */
    public void afterReturningAdvice(Object retVal){
        System.out.println("return-----Returning:" + retVal );
    }
    /**
     * This is the method which I would like to execute
     * if there is an exception raised.
     */
    public void AfterThrowingAdvice(IllegalArgumentException ex){
        System.out.println("ex-----------There has been an exception: " + ex.toString());
    }

    /**
     * 环绕操作
     * @param pjp
     * @return
     * @throws Throwable
     */
    public Object around(ProceedingJoinPoint pjp) throws Throwable {
        System.out.println(pjp);
        return pjp.proceed();
    }
}
